#include "TestGroupBoxForm.h"


#define BUTTON3_ID 1


TestGroupBoxForm::TestGroupBoxForm() {

	this->CreatedEvent.Register(this, &TestGroupBoxForm::OnCreated);
}



TestGroupBoxForm::~TestGroupBoxForm() {

}



void TestGroupBoxForm::OnCreated(CreatedEventArgs& args) {

	this->SetSize(500, 400);

	m_groupBox.SetText(L"GroupBox");
	m_groupBox.SetSize(200, 150);
	m_groupBox.SetPosition(0, 0);
	m_groupBox.SetParent(*this);
	m_groupBox.Create();

	m_button1.SetText(L"Button1");
	m_button1.SetSize(100, 30);
	m_button1.SetPosition(25, 20);
	m_button1.SetParent(m_groupBox);
	m_button1.Create();

	m_button2.SetText(L"Button2");
	m_button2.SetSize(100, 30);
	m_button2.SetPosition(25, 50);
	m_button2.SetParent(m_groupBox);
	m_button2.Create();

	m_button3.SetText(L"Move the box");
	m_button3.SetSize(100, 30);
	m_button3.SetPosition(250, 0);
	m_button3.SetParent(*this);
	m_button3.SetID(BUTTON3_ID);
	m_button3.Create();
}



LRESULT TestGroupBoxForm::WndProc(const WndMsg& msg) {

	switch (msg.Message) {

	case WM_COMMAND: 
		if (msg.WParamHigh == BN_CLICKED) {

			switch (msg.WParamLow) {

			case BUTTON3_ID: {
				unsigned int x;
				unsigned int y;

				m_groupBox.GetPosition(x, y);

				x = (x + 1) % 30;
				y = (y + 1) % 30;

				m_groupBox.SetPosition(x, y);
				return TRUE;
							 }
			}
		}
		break;
	}

	return Form::WndProc(msg);
}